# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=XML-LibXML
pkgname=perl-${_realname}
pkgver=2.0121
pkgrel=1
pkgdesc="Expat-based XML parser module for perl"
arch=('i686' 'x86_64')
license=('GPL' 'PerlArtistic')
url="https://bitbucket.org/shlomif/perl-xml-libxml/"
groups=('perl-modules')
depends=('perl' 'libxml2' 'perl-XML-SAX')
makedepends=('libxml2-devel')
#replaces=('perlxml')
#provides=("perlxml=${pkgver}")
options=('!emptydirs')
source=("http://search.cpan.org/CPAN/authors/id/S/SH/SHLOMIF/${_realname}-${pkgver}.tar.gz"
        'XML-LibXML-2.0002.patch')
md5sums=('1544ab9ac110f5da296015346561ce02'
         'bfea701f068d4f3dad9fad453af5a340')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"

  patch -p1 -i ${srcdir}/XML-LibXML-2.0002.patch
}

build() {
  cd "${srcdir}/${_realname}-${pkgver}"

  # install module in vendor directories.
  perl Makefile.PL INSTALLDIRS=vendor
  make
}

check() {
  cd "${srcdir}/${_realname}-${pkgver}"
  make test
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"
  make install DESTDIR="${pkgdir}"

  # remove perllocal.pod and .packlist.
  find "${pkgdir}" -name perllocal.pod -delete
  find "${pkgdir}" -name .packlist -delete

  # fix permissions
  find ${pkgdir}/usr -type f -name *.dll | xargs chmod 0755
}
